﻿// -----------------------------------------------------------------------
// <copyright file="CancelResponse.cs" company="Zen Design Corp">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Zen.BlackBerry.Pap.Parser
{
	using System.Collections.Generic;
	using System.Xml;
	using System.Xml.Serialization;

	/// <summary>
	/// Represents the response from a cancel request message.
	/// </summary>
	public class CancelResponse : PapMessage
	{
		private List<CancelResult> _results;

		/// <summary>
		/// Gets or sets the results.
		/// </summary>
		/// <value>The results.</value>
		[XmlArray(ElementName = "cancel-result")]
		public List<CancelResult> Results
		{
			get
			{
				if (_results == null)
				{
					_results = new List<CancelResult>();
				}
				return _results;
			}
			set
			{
				_results = value;
			}
		}
	}

	/// <summary>
	/// Represents a result within a <see cref="CancelResponse"/>.
	/// </summary>
	public class CancelResult : ResponseResult
	{
		private AddressList _addresses;

		/// <summary>
		/// Gets the addresses.
		/// </summary>
		/// <value>The addresses.</value>
		public AddressList Addresses
		{
			get
			{
				if (_addresses == null)
				{
					_addresses = new AddressList();
				}
				return _addresses;
			}
		}

		/// <summary>
		/// Reads the XML.
		/// </summary>
		/// <param name="reader">The reader.</param>
		public override void ReadXml(XmlReader reader)
		{
			base.ReadXml(reader);

			Addresses.Clear();
			Addresses.ReadXml(reader);
		}
	}
}
